package com.mjh.zhujianju.controller.qiandao;

import javax.annotation.Resource;

import com.livew.framework.utils.XTCurrentUser;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.livew.framework.exception.XTBusinessException;
import com.mjh.zhujianju.service.party.BuildingMeetingService;
import com.mjh.zhujianju.util.ApiConstant;
import com.mjh.zhujianju.util.JsonResult;

@RestController
@RequestMapping("signIn")
public class QianDaoController {

	@Resource
	private BuildingMeetingService buildingMeetingService;
	
	/**
	 * 会议签到
	 * @param meetId
	 * @return
	 */
	@RequestMapping("meeting/{id}")
    public ResponseEntity<JsonResult> meeting (@PathVariable("id")Long meetId){
        JsonResult result = new JsonResult();
        try {
			Long userId = XTCurrentUser.getCurrentUserId();
			if (null !=userId){
				buildingMeetingService.updateUsersStatus(meetId,userId);
			}else {
				result.setResult("请先登录");
				result.setStatus(ApiConstant.MSG_NO_USER);
				return ResponseEntity.ok(result);
			}
		} catch (XTBusinessException e) {
			e.printStackTrace();
			result.setResult(e.getMessage());
			result.setStatus(ApiConstant.MSG_SUCCESS);
			return ResponseEntity.ok(result);
		}
        result.setResult("签到成功");
		result.setStatus(ApiConstant.MSG_SUCCESS);
		return ResponseEntity.ok(result);
	}
}
